Quản lý nhân sự công ty bằng c# _ full source code
60.462 lượt xem;
- frmbangtileluong.cs
- QuanLyNhanSu /
- project /
1 using System;
2 using System.Collections.Generic;
3 using System.ComponentModel;
4 using System.Data;
5 using System.Drawing;
6 using System.Text;
7 using System.Windows.Forms;
8 using System.Data.SqlClient;
9 using Telerik.Data;
10 using Telerik.WinControls.UI;
11 using QuanLyNhanSu.Class;
12 using Telerik.WinControls;
13
14
15 namespace QuanLyNhanSu
16 {
17 public partial class frmbangtileluong : RadForm
18 {
19 //khai báo biến toàn cục
20 clsTiLeLuong ctileluong = new clsTiLeLuong();
21 clsdmpb cPhong = new clsdmpb();
22 clsDMTo cTo = new clsDMTo();
23 int k = 0;
24 public frmbangtileluong()
25 {
26 InitializeComponent();
27 ctileluong.laydl();
28 for (int i = 1; i <= 12; i++)
29 {
30 cbothang.Items.Add(i);
31 }
32 for (int i = 2008; i <= 2100; i++)
33 {
34 cbonam.Items.Add(i);
35 }
36 cboPhong.DataSource = cPhong.taocombo();
37 cboPhong.DisplayMember = "tbl_PhongBan.TenPhong";
38 cboPhong.ValueMember = "tbl_PhongBan.MaPhong";
39
40 dgv_TiLeLuong.DataSource = ctileluong.ds;
41 dgv_TiLeLuong.DataMember = "TiLeLuong";
42 dgv_TiLeLuong.Columns[0].IsVisible = false;
43 dgv_TiLeLuong.Columns[1].IsVisible = false;
44 dgv_TiLeLuong.Columns[2].HeaderText = "Tháng";
45 dgv_TiLeLuong.Columns[3].HeaderText = "Năm";
46 dgv_TiLeLuong.Columns[4].HeaderText = "Phòng";
47 dgv_TiLeLuong.Columns[5].HeaderText = "Tổ";
48 dgv_TiLeLuong.Columns[6].HeaderText = "Tỷ lệ lương";
49 dgv_TiLeLuong.Columns[7].HeaderText = "Số ngày công";
50
51
52 }
53
54
55 private void frmbangtileluong_Load(object sender, EventArgs e)
56 {
57 setcmd(true);
58 setcontrol(false);
59 HienThiDL();
60 }
61 //set bộ nút
62 private void setcmd(bool b)
63 {
64 cmdCapnhat.Enabled = b;
65 cmdluu.Enabled = !b;
66 cmdthoat.Enabled = b;
67 cmdthem.Enabled = b;
68 cmdxoa.Enabled = b;
69 }
70 // set control
71 private void setcontrol(bool b)
72 {
73 foreach (Control c in pnlthongtin.Controls)
74 {
75 if (c.Name.Contains("txt")==true ||c.Name.Contains("cbo")==true )
76 c.Enabled = b;
77 }
78 }
79 //
80 private void HienThiDL()
81 {
82
83 if (dgv_TiLeLuong.CurrentRow!=null)
84 {
85
86
87 cbothang.Text = dgv_TiLeLuong.CurrentRow.Cells["thang"].Value.ToString();
88 cbonam.Text = dgv_TiLeLuong.CurrentRow.Cells["nam"].Value.ToString();
89 cboPhong.Text = dgv_TiLeLuong.CurrentRow.Cells["tenphong"].Value.ToString();
90 cboto.Text = dgv_TiLeLuong.CurrentRow.Cells["tento"].Value.ToString();
91 txttll.Text = dgv_TiLeLuong.CurrentRow.Cells["tileluong"].Value.ToString();
92 txtsongaycong.Text = dgv_TiLeLuong.CurrentRow.Cells["songaycongthang"].Value.ToString();
93 }
94 }
95
96 private void cmdthoat_Click(object sender, EventArgs e)
97 {
98 Close();
99 }
100
101 private void cboPhong_SelectedIndexChanged(object sender, EventArgs e)
102 {
103 cboto.DataSource = cTo.taocombo(cboPhong.SelectedValue.ToString());
104 cboto.DisplayMember = "DanhMucTo.TenTo";
105 cboto.ValueMember = "DanhMucTo.MaTo";
106 cboto.Text = "";
107 }
108
109 private void cmdthem_Click(object sender, EventArgs e)
110 {
111 setcmd(false);
112 setcontrol(true);
113 txttll.Text = "";
114 txtsongaycong.Text = "";
115 k = 1;
116 }
117
118 private void cmdCapnhat_Click(object sender, EventArgs e)
119 {
120 if (dgv_TiLeLuong.SelectedRows.Count == 0)
121 {
122 RadMessageBox.Show("\nBạn phải chọn dòng để cập nhật !\n", "Thông Báo", MessageBoxButtons.OK, RadMessageIcon.Question);
123 return;
124 }
125 else
126 {
127
128 setcmd(false);
129 txttll.Enabled = true;
130 txtsongaycong.Enabled = true;
131 txttll.Focus();
132 k = 2;
133 }
134 }
135
136 private void dgv_TiLeLuong_Click(object sender, EventArgs e)
137 {
138 //HienThiDL(dgv_TiLeLuong.CurrentRow);
139 }
140
141 private void cmdxoa_Click(object sender, EventArgs e)
142 {
143 if (dgv_TiLeLuong.SelectedRows.Count == 0)
144 {
145 RadMessageBox.Show("\nBạn phải chọn dòng để xóa !\n", "Thông Báo",MessageBoxButtons.OK, RadMessageIcon.Question);
146 return;
147 }
148 else
149 {
150 DialogResult rs = RadMessageBox.Show("\nBạn muốn xóa ? \n", "Thông Báo", MessageBoxButtons.YesNo, RadMessageIcon.Question);
151 if (rs == DialogResult.Yes)
152 {
153 ctileluong.xoa(dgv_TiLeLuong.CurrentRow.Cells["id"].Value.ToString());
154 ctileluong.laydl();
155 }
156 }
157 }
158
159 private void cmdluu_Click(object sender, EventArgs e)
160 {
161 DialogResult rs = RadMessageBox.Show("Bạn muốn lưu lai không?","Thông báo",MessageBoxButtons.YesNo,RadMessageIcon.Question );
162 if (rs == DialogResult.Yes)
163 {
164 if (k == 1)
165 if (cboto.SelectedItem != null)
166 {
167 ctileluong.them(int.Parse(cbothang.Text.Trim()),
168 int.Parse(cbonam.Text.Trim()),
169 cboPhong.SelectedValue.ToString().Trim(),
170 cboto.SelectedValue.ToString().Trim(),
171 txttll.Text != "" ? double.Parse(txttll.Text.Trim()) : 1,
172 txtsongaycong.Text != "" ? int.Parse(txtsongaycong.Text.Trim()) : 26);
173 }
174 else
175 {
176 ctileluong.them(int.Parse(cbothang.Text.Trim()),
177 int.Parse(cbonam.Text.Trim()),
178 cboPhong.SelectedValue.ToString().Trim(),
179 txttll.Text != "" ? double.Parse(txttll.Text.Trim()) : 1,
180 txtsongaycong.Text != "" ? int.Parse(txtsongaycong.Text.Trim()) : 26);
181 }
182 else
183 if (k == 2)
184 {
185 ctileluong.sua(dgv_TiLeLuong.CurrentRow.Cells["id"].Value.ToString(),
186 txttll.Text != "" ? double.Parse(txttll.Text.Trim()) : 1,
187 txtsongaycong.Text != "" ? int.Parse(txtsongaycong.Text.Trim()) : 26);
188 }
189 }
190 k = 0;
191 setcontrol(false);
192 setcmd(true);
193 ctileluong.laydl();
194 }
195
196
197
198
199
200
201
202 }
203 }
2 using System.Collections.Generic;
3 using System.ComponentModel;
4 using System.Data;
5 using System.Drawing;
6 using System.Text;
7 using System.Windows.Forms;
8 using System.Data.SqlClient;
9 using Telerik.Data;
10 using Telerik.WinControls.UI;
11 using QuanLyNhanSu.Class;
12 using Telerik.WinControls;
13
14
15 namespace QuanLyNhanSu
16 {
17 public partial class frmbangtileluong : RadForm
18 {
19 //khai báo biến toàn cục
20 clsTiLeLuong ctileluong = new clsTiLeLuong();
21 clsdmpb cPhong = new clsdmpb();
22 clsDMTo cTo = new clsDMTo();
23 int k = 0;
24 public frmbangtileluong()
25 {
26 InitializeComponent();
27 ctileluong.laydl();
28 for (int i = 1; i <= 12; i++)
29 {
30 cbothang.Items.Add(i);
31 }
32 for (int i = 2008; i <= 2100; i++)
33 {
34 cbonam.Items.Add(i);
35 }
36 cboPhong.DataSource = cPhong.taocombo();
37 cboPhong.DisplayMember = "tbl_PhongBan.TenPhong";
38 cboPhong.ValueMember = "tbl_PhongBan.MaPhong";
39
40 dgv_TiLeLuong.DataSource = ctileluong.ds;
41 dgv_TiLeLuong.DataMember = "TiLeLuong";
42 dgv_TiLeLuong.Columns[0].IsVisible = false;
43 dgv_TiLeLuong.Columns[1].IsVisible = false;
44 dgv_TiLeLuong.Columns[2].HeaderText = "Tháng";
45 dgv_TiLeLuong.Columns[3].HeaderText = "Năm";
46 dgv_TiLeLuong.Columns[4].HeaderText = "Phòng";
47 dgv_TiLeLuong.Columns[5].HeaderText = "Tổ";
48 dgv_TiLeLuong.Columns[6].HeaderText = "Tỷ lệ lương";
49 dgv_TiLeLuong.Columns[7].HeaderText = "Số ngày công";
50
51
52 }
53
54
55 private void frmbangtileluong_Load(object sender, EventArgs e)
56 {
57 setcmd(true);
58 setcontrol(false);
59 HienThiDL();
60 }
61 //set bộ nút
62 private void setcmd(bool b)
63 {
64 cmdCapnhat.Enabled = b;
65 cmdluu.Enabled = !b;
66 cmdthoat.Enabled = b;
67 cmdthem.Enabled = b;
68 cmdxoa.Enabled = b;
69 }
70 // set control
71 private void setcontrol(bool b)
72 {
73 foreach (Control c in pnlthongtin.Controls)
74 {
75 if (c.Name.Contains("txt")==true ||c.Name.Contains("cbo")==true )
76 c.Enabled = b;
77 }
78 }
79 //
80 private void HienThiDL()
81 {
82
83 if (dgv_TiLeLuong.CurrentRow!=null)
84 {
85
86
87 cbothang.Text = dgv_TiLeLuong.CurrentRow.Cells["thang"].Value.ToString();
88 cbonam.Text = dgv_TiLeLuong.CurrentRow.Cells["nam"].Value.ToString();
89 cboPhong.Text = dgv_TiLeLuong.CurrentRow.Cells["tenphong"].Value.ToString();
90 cboto.Text = dgv_TiLeLuong.CurrentRow.Cells["tento"].Value.ToString();
91 txttll.Text = dgv_TiLeLuong.CurrentRow.Cells["tileluong"].Value.ToString();
92 txtsongaycong.Text = dgv_TiLeLuong.CurrentRow.Cells["songaycongthang"].Value.ToString();
93 }
94 }
95
96 private void cmdthoat_Click(object sender, EventArgs e)
97 {
98 Close();
99 }
100
101 private void cboPhong_SelectedIndexChanged(object sender, EventArgs e)
102 {
103 cboto.DataSource = cTo.taocombo(cboPhong.SelectedValue.ToString());
104 cboto.DisplayMember = "DanhMucTo.TenTo";
105 cboto.ValueMember = "DanhMucTo.MaTo";
106 cboto.Text = "";
107 }
108
109 private void cmdthem_Click(object sender, EventArgs e)
110 {
111 setcmd(false);
112 setcontrol(true);
113 txttll.Text = "";
114 txtsongaycong.Text = "";
115 k = 1;
116 }
117
118 private void cmdCapnhat_Click(object sender, EventArgs e)
119 {
120 if (dgv_TiLeLuong.SelectedRows.Count == 0)
121 {
122 RadMessageBox.Show("\nBạn phải chọn dòng để cập nhật !\n", "Thông Báo", MessageBoxButtons.OK, RadMessageIcon.Question);
123 return;
124 }
125 else
126 {
127
128 setcmd(false);
129 txttll.Enabled = true;
130 txtsongaycong.Enabled = true;
131 txttll.Focus();
132 k = 2;
133 }
134 }
135
136 private void dgv_TiLeLuong_Click(object sender, EventArgs e)
137 {
138 //HienThiDL(dgv_TiLeLuong.CurrentRow);
139 }
140
141 private void cmdxoa_Click(object sender, EventArgs e)
142 {
143 if (dgv_TiLeLuong.SelectedRows.Count == 0)
144 {
145 RadMessageBox.Show("\nBạn phải chọn dòng để xóa !\n", "Thông Báo",MessageBoxButtons.OK, RadMessageIcon.Question);
146 return;
147 }
148 else
149 {
150 DialogResult rs = RadMessageBox.Show("\nBạn muốn xóa ? \n", "Thông Báo", MessageBoxButtons.YesNo, RadMessageIcon.Question);
151 if (rs == DialogResult.Yes)
152 {
153 ctileluong.xoa(dgv_TiLeLuong.CurrentRow.Cells["id"].Value.ToString());
154 ctileluong.laydl();
155 }
156 }
157 }
158
159 private void cmdluu_Click(object sender, EventArgs e)
160 {
161 DialogResult rs = RadMessageBox.Show("Bạn muốn lưu lai không?","Thông báo",MessageBoxButtons.YesNo,RadMessageIcon.Question );
162 if (rs == DialogResult.Yes)
163 {
164 if (k == 1)
165 if (cboto.SelectedItem != null)
166 {
167 ctileluong.them(int.Parse(cbothang.Text.Trim()),
168 int.Parse(cbonam.Text.Trim()),
169 cboPhong.SelectedValue.ToString().Trim(),
170 cboto.SelectedValue.ToString().Trim(),
171 txttll.Text != "" ? double.Parse(txttll.Text.Trim()) : 1,
172 txtsongaycong.Text != "" ? int.Parse(txtsongaycong.Text.Trim()) : 26);
173 }
174 else
175 {
176 ctileluong.them(int.Parse(cbothang.Text.Trim()),
177 int.Parse(cbonam.Text.Trim()),
178 cboPhong.SelectedValue.ToString().Trim(),
179 txttll.Text != "" ? double.Parse(txttll.Text.Trim()) : 1,
180 txtsongaycong.Text != "" ? int.Parse(txtsongaycong.Text.Trim()) : 26);
181 }
182 else
183 if (k == 2)
184 {
185 ctileluong.sua(dgv_TiLeLuong.CurrentRow.Cells["id"].Value.ToString(),
186 txttll.Text != "" ? double.Parse(txttll.Text.Trim()) : 1,
187 txtsongaycong.Text != "" ? int.Parse(txtsongaycong.Text.Trim()) : 26);
188 }
189 }
190 k = 0;
191 setcontrol(false);
192 setcmd(true);
193 ctileluong.laydl();
194 }
195
196
197
198
199
200
201
202 }
203 }